<template name='pick_records_huizong'>

<view >

	<!-- 商品信息-右边 -->
	<view class="box-infos font12  " >
	
		<view class="content-box ">
			
				<view class="boxsss" >
					<!-- 增加、删除 -->
					<view class="top-but menu-scroll-w">
						<view class="top-but-box ">
							
							<!-- 时间 筛选 -->
							<!-- <text selectable="true"  class="justify">时间范围:</text> -->
							<view class=" date-center floatleft" >
								
								<picker class="date-left" 
								mode="date" 
								:value="search.date[0]" 
								@change="changeStartDate"
								>
									<view class="uni-input cursor">{{search.date.length >0 ? search.date[0]:'开始时间'}}</view>
								</picker>
								
								<view class="date-c"> - </view>
								
								<picker class="date-left" 
								mode="date" 
								:value="search.date[1]" 
								@change="changeEndDate"
								>
									<view class="uni-input cursor">{{search.date.length >1 ? search.date[1]:'结束时间'}}</view>
								</picker>
								
								<view class="delete-ipu" 
								style="position: unset;transform: none;"
								v-if="search.date.length >1" 
								@click="search.date=[],funOrderAllAdmin(true)"
								>
									<img src="../../static/img/delete-1.png"  ></img>
								</view>
							</view>
							<!-- end -->
							
						
					
						
							<!-- end -->
							<!-- 线路 筛选 -->
							<view class="flex floatleft" >
								<text selectable="true"  class="riskTitle " >选择线路:</text>
								<view class="input_confirms" >
									<uni-data-select
									:localdata="$routeData.getRoute()"
									v-model="search.route_id"
									placeholder="选择线路"
									placeholder-class="placeholder-class"
									class="color-e40318"
									></uni-data-select>
								</view>
							</view>
							<!-- end -->
							
							<!-- 搜索员工 -->
							<view class="flex floatleft" >
								<text selectable="true"  class="riskTitle " >操作者:</text>
								<view class="input_confirms" >
									<uni-data-select
									:localdata="$routeData.getYuangong()"
									v-model="search.YuangongId"
									placeholder="选择操作者"
									placeholder-class="placeholder-class"
									class="color-e40318"
									></uni-data-select>
								</view>
							</view>
							<!-- end -->
							
							
							<!-- 客户名称-->
							<view class="flex floatleft" >
								<text selectable="true"  class="riskTitle " >客户名称:</text>
								<!-- 搜索 -->
								<view class="searchBox" style="min-width: 100px;max-width: 150px;">
									<input 
									v-model="search.user_value"
									placeholder="输入搜索关键字"
									placeholder-class="placeholder-class"
									@confirm="$common.noMultipleClicks('funOrderAllAdmin',funOrderAllAdmin,true)"
									class="search-ipu "
									/>
									<view class="delete-ipu" v-if="search.user_value!=''" @click="search.user_value='',funOrderAllAdmin(true)">
										<img src="../../static/img/delete-1.png"  ></img>
									</view>
								</view>
							</view>
							<!-- end -->
							
							<!-- 商品名称-->
							<view class="flex floatleft" >
								<text selectable="true"  class="riskTitle " >商品名称:</text>
								<!-- 搜索 -->
								<view class="searchBox" style="min-width: 100px;max-width: 150px;">
									<input 
									v-model="search.goods_value"
									
									placeholder="输入搜索关键字"
									placeholder-class="placeholder-class"
									@confirm="$common.noMultipleClicks('funOrderAllAdmin',funOrderAllAdmin,true)"
									class="search-ipu "
									/>
									<view class="delete-ipu" v-if="search.goods_value!=''" @click="search.goods_value='',funOrderAllAdmin(true)">
										<img src="../../static/img/delete-1.png"  ></img>
									</view>
								</view>
							</view>
							<!-- end -->
							
							<!-- 订单号-->
							<view class="flex floatleft" >
								<text selectable="true"  class="riskTitle " >订单号:</text>
								<!-- 搜索 -->
								<view class="searchBox" style="min-width: 100px;max-width: 150px;">
									<input 
									v-model="search.order_id"
									
									placeholder="输入搜索订单号关键字"
									placeholder-class="placeholder-class"
									@confirm="$common.noMultipleClicks('funOrderAllAdmin',funOrderAllAdmin,true)"
									class="search-ipu "
									/>
									<view class="delete-ipu" v-if="search.order_id!=''" @click="search.order_id='',funOrderAllAdmin(true)">
										<img src="../../static/img/delete-1.png"  ></img>
									</view>
								</view>
							</view>
							<!-- end -->
									
							<!-- 时间 筛选 -->
							<view 
								@click="$common.noMultipleClicks('funOrderAllAdmin',funOrderAllAdmin,true)" 
								class="rightButttom" 
							>
								<img src="../../static/img/search.png" class="ico"></img>
								刷新
							</view>
							
							<view 
								@click="emptyData()" 
								class="back_color search-but floatleft" 
							>
								<img src="../../static/img/delete.png" class="ico"></img>
								重置
							</view>
						
						</view>
					</view>
					<table v-if="resData.list!=undefined && resData.list.length>0">
						<!-- 表头 -->
						<thead>
							<tr >
								<th style="min-width: 20px;">
									序
								</th>
								<th class="centers">操作者</th>
								<th class="centers">数量</th>
								<th class="centers">金额</th>
								<th class="centers">利润</th>
							</tr>
						</thead>
						<tbody>
						
								<!-- 内容 -->
								<tr v-for="(item,index) in resData.list" 
								:key="index"  
								@click="TabcheckedIndex = index"
								:class="TabcheckedIndex == index ? 'goods-list-select':''"
								>
									<td>
										{{index+1}}
									</td>
									<td class="centers cursor alter" @click="fun_info(item.uids,item.uids_name)">
										{{item.uids_name}}
									</td>
									<td class="centers">
										{{item.count}}
									</td>
									<td class="centers">
										{{item.sum_money}}
									</td>
									<td class="centers">
										{{item.profit}}
									</td>
									
								</tr>
						
						</tbody>
					</table>
					
					<!-- 暂无数据 -->
					<empty v-if="resData.list==undefined || resData.list.length==0"></empty>
					<!-- end -->
				</view>
				<!-- 合计 -->
				<view class="flex bottom c565656 font12" v-if="resData.list && resData.list.length>0">
					<view class="flex">
						<view class="justify">合计: </view>
						<view class="ipu flex border1 ">
							<view class="justify money ">{{resData.list.length}}</view>
							<view class="justify">个操作者</view>
						</view>
					</view>
					<view style="height: 1px;width: 20px;"></view>
					<view class="flex">
						<view class="justify">数量为: </view>
						<view class="ipu flex border1 ">
							<view class="justify money ">{{resData.data.count}}</view>
						</view>
					</view>
					<view style="height: 1px;width: 20px;"></view>
					<view class="flex">
						<view class="justify">金额为: </view>
						<view class="ipu flex border1 ">
							<view class="justify money ">{{resData.data.money.toFixed(2)}}</view>
						</view>
					</view>
					<view style="height: 1px;width: 20px;"></view>
					<view class="flex">
						<view class="justify">利润为: </view>
						<view class="ipu flex border1 ">
							<view class="justify money ">{{resData.data.profit.toFixed(2)}}</view>
						</view>
					</view>
					<!-- <view style="height: 1px;width: 20px;"></view>
					<view class="flex">
						<view class="justify">利率: </view>
						<view class="ipu flex border1 ">
							<view class="justify money ">{{resData.data!=undefined ? resData.data.profit_ratio:0}}</view>
							<view class="justify">%</view>
						</view>
					</view>
					<view style="height: 1px;width: 20px;"></view>
					<view class="flex ">
						<view class="justify">计算公式: </view>
						<view class="justify">在指定的筛选条件内所有已过账的单据款合计总金额-各个商品的进货价=利润</view>
					</view> -->
					
				</view>
				<!-- end -->
			<!-- end -->
			
		
			<!-- 页码 -->
			<pages 
			:sum="page.sum"
			:current="page.nowPage"
			@updatePage="updatePage"
			></pages>
			<!-- end -->
		</view>
		<!-- 数据列表end -->
	</view>
	<!-- end -->
	
	<!-- 详情页 -->
	<uni-popup ref="pick_info" type="center" :title="OnSearch.username+' 的记录'" 
	>
		<pick_records
		:onSearch="OnSearch" 
		class="page-boxs h100"
		></pick_records>	
	</uni-popup>
	<!-- end -->
</view>

</template>

<script>
	import pages from "@/components/admin-components/pages.vue"

	import empty from "@/components/admin-components/empty.vue"
	import pick_records from "@/pages/pick/records.vue"

	
	export default{
		name:'pick_records_huizong',
		components: {
			pages,pick_records,empty
		},
		beforeCreate(){
			this.$options.components.order_money = require('@/components/admin-components/order_money.vue').default 
		},
		data(){
			return{
				TabcheckedIndex:-1,//当前选中项
				
			
				OnSearch:{},
				search:{
					YuangongId:'',
					date:[],
					user_value:'',
					uid_value:'',
					goods_value:'',
					order_id:'',
					route_id:''
				},
				page:{
					
					nowPage:1,//当前页数
					pageCount:1,//总页数
					maxCount:0,
					sum:0,
					pageCounts:15,
				},
			
				resData:{},
				
			}
		},
		 // 此处定义传入的数据
		props: {
			/**
			 * 其他页面传递进来直接搜寻的，不是菜单打开的
			*/
			OnPageSearchUid: {
				type:String,
				default :''
			},
			/**
			 * 时间范围 开始
			*/
			start_date: {
				type:String,
				default :''
			},
			/**
			 * 时间范围 结束
			*/
			end_date: {
				type:String,
				default :''
			},
			/**
			 * 区分供货商或客户
			*/
			supplier: {
				type:String,
				default :''
			},
			/**
			 * 区分拣货还是分货
			*/
			actionType: {
				type:String,
				default :'0'
			},
		},
		mounted(){
		},
		created() {
			//判断是否有搜索内容，有的话植入，且搜索条件为：只看客户
			if(this.OnPageSearchUid != undefined && this.OnPageSearchUid != ''){
				this.search.uid_value = this.OnPageSearchUid
				
				
				//console.log("//判断是否有搜索内容，有的话植入，且搜索条件为：只看客户")
			}else{
//				console.log("//客户")
				//判断是有  时间条件
				if(this.start_date != undefined && this.start_date.length>0 && this.end_date != undefined && this.end_date.length>0){
					this.search.date.push(this.start_date)
					this.search.date.push(this.end_date)
				}else{
					var date = this.$common.GetFormattedDate()
					this.search.date.push(date)
					this.search.date.push(date)
				}
			}
			
			//不是模块打开的华就提取线路
			let route = this.$routeData.GetNowRoute()
			this.search.route_id = route

			this.funOrderAllAdmin(true)
		},
		methods:{
		
			
			//回调第一个时间
			changeStartDate(res){
				this.search.date[0] = res.detail.value
				this.$set(this.search.date,0,this.search.date[0])
				
			},
			//回调第二个时间
			changeEndDate(res){
				this.search.date[1] = res.detail.value
				this.$set(this.search.date,1,this.search.date[1])
			},
		
			/**
			 * 打开详情
			*/
			fun_info(uids,name){
			
				this.OnSearch = JSON.parse(JSON.stringify(this.search))
				this.OnSearch.yuangongId = uids
				this.OnSearch.username = name
				this.OnSearch.actionType = this.actionType
				
				
				this.$refs.pick_info.open()
			},
		
			
			
			/**
			 * 初始化筛选条件
			*/
			emptyData(){
				this.search.user_value=''
				this.search.uid_value =''
				this.search.date =[]
				
				
				this.search.route_id = ''
				this.funOrderAllAdmin(true)
			},
			/**
			 * 线路ID取线路名称
			*/
			routeidGetName(id){
				var tmpArr = this.$routeData.getRoute()
				
				for (var i=0;i<tmpArr.length;i++) {
					if(tmpArr[i].value == id){
						return tmpArr[i].text
					}
				}
				return '-'
			},
			/**
			 * 统计-获取
			*/
			funOrderAllAdmin(isUpdatePage=true){
				var that = this
				//日期构建
				if(that.search.date.length>=2){
					var start_date = that.search.date[0]
					var end_date = that.search.date[1]
				}else{
					var start_date = ''
					var end_date = ''
				}
				that.resData = {}
				that.page.nowPage = isUpdatePage == true ? 1:that.page.nowPage;
				that.$common.get_request(
					{
						type:that.actionType==2 ? 'ps_list_records_huizong':'jh_list_records_huizong',
						pages:that.page.nowPage,
						page_count:that.page.pageCounts,//当前请求页的数量
						start_date: start_date,
						end_date: end_date,
						route_id: that.search.route_id,
						goods_value: that.search.goods_value,
						order_id: that.search.order_id,
						user_value:that.search.user_value,
						yuangong_id:that.search.YuangongId,
						actionType:that.actionType
					},
					(res)=>{
						for (var i=0;i<res.list.length;i++) {
							res.list[i].route_name = that.routeidGetName(res.list[i].route_id)
						}
						that.resData = res
						
						that.page.sum  = res.sum
						if(isUpdatePage == true){
						that.page.nowPage  = 1
						}
						
					}
				);
			},
			/**
			 * 分页器回调
			 * 
			*/
			updatePage(pageName,pageCount){
				var that = this
				that.page.nowPage = pageName
				that.page.pageCounts = pageCount
				that.funOrderAllAdmin(false)
			},
		}
	}
</script>

<style>
</style>
